<?php

class Public_Comment_ModerationAction extends BlogPublicBaseAction
{
    public function executeRead(AgaviRequestDataHolder $rd)
    {
        return 'Success';
    }
    
    public function executeWrite(AgaviRequestDataHolder $rd)
    {
        $params = $rd->getParameters();
        /* @var $comments_model Public_CommentsModel */
        $comments_model = $this->getContext()->getModel('Comments', 'Public');
        
        if (isset($params['action_type']) && $params['action_type']==='mass-delete') {
            // $params['comments'] contains list of comments to delete
            $comments_model->deleteComments($params['comments']);
        }
        return 'MassDeleteSuccess';
    }
    
	/**
	 * Returns the default view if the action does not serve the request
	 * method used.
	 *
	 * @return     mixed <ul>
	 *                     <li>A string containing the view name associated
	 *                     with this action; or</li>
	 *                     <li>An array with two indices: the parent module
	 *                     of the view to be executed and the view to be
	 *                     executed.</li>
	 *                   </ul>
	 */
	public function getDefaultViewName()
	{
		return 'Success';
	}
	
    public function isSecure()
    {
        return TRUE;
    }
	
    public function getCredentials()
    {
        return array('comments.moderator');
    }
    
}

?>